package A02practicemulti;

public class Person {
    String name;
    int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public void keepPet(Animal animal) {
        if (animal instanceof Cat cat) {
            cat.eat("fish");
            System.out.println("猫吃着鱼");
        }
        else if (animal instanceof Dog dog) {
            dog.eat("bone");
            System.out.println("狗啃着骨头");
        }
        else{
            System.out.println("什么东西我不道啊");
        }
    }
}
